from selenium import webdriver
import time
#driver = webdriver.Chrome(r'D:\xuexi\chromedriver')
#driver = webdriver.Chrome()
#driver = webdriver.Ie()
driver = webdriver.Firefox()
driver.maximize_window()
driver.get('https://www.baidu.com')
#driver.find_element_by_id('kw').send_keys('我要自学网') #id
#time.sleep(3)
#driver.find_element_by_name('wd').send_keys('我要自学网') #name
#time.sleep(3)
#driver.find_element_by_class_name('s_ipt').send_keys('我要自学网') #class_name
#time.sleep(3)
#driver.find_element_by_tag_name('input').send_keys('我要自学网') #tag_name(失败tag在一个页面中，相同的标签有很多，所以一般不用标签来定位)
#time.sleep(3)
#driver.find_element_by_link_text('hao123').click() #link_text
#time.sleep(3)
#driver.find_element_by_partial_link_text('ao12').clink() #(失败)partial_link_text
#time.sleep(3)
#driver.find_element_by_xpath('//*[@id="kw"]').send_keys('我要自学网') #xpath(谷歌浏览器定位_右键复制xpath)
#time.sleep(3)
driver.find_element_by_css_selector('#kw').send_keys('我要自学网') #(失败)xpath（火狐浏览器定位_右键复制css）
time.sleep(3)
driver.quit()
